package com.itheima.controller;

import com.itheima.domain.User;
import com.itheima.service.UserService;
import com.itheima.service.impl.UserServiceImpl;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class UserController {
    private UserService userService = new UserServiceImpl();
    private User user = null;
    //查询全部
    @Test
    public void testFindAll(){
        List<User> list = userService.findAll();
        System.out.println(list);
    }
    //通过id查询
    @Test
    public void testFindById(){
        user = userService.findById(26);
        System.out.println(user);
    }
    //登录测试
    @Test
    public void testLogin(){
        user = userService.findByNameAndPwd("大乔","666");
        System.out.println(user);
    }
    //多条件查询
    @Test
    public void testFindCondition(){
        user = new User();
        user.setId(26);
        user.setUsername("大乔");
        //user.setPwd("666");
        List<User> list = userService.findCondition(user);
        System.out.println(list);
    }
    //根据多个ID查询
    @Test
    public void testFindByIds(){
        user = new User();
        List<Integer> lists = new ArrayList<Integer>();
        lists.add(1);
        lists.add(2);
        lists.add(3);
        lists.add(4);
        //user.setPwd("666");
        List<User> list = userService.findByIds(lists);
        System.out.println(list);
    }
}
